package org.lex.io.filesystem.tools;

import java.io.File;

import org.lex.filter.Filter;
import org.lex.io.filesystem.traveller.FileProcessor;
import org.lex.io.filesystem.traveller.FileTraveller;


public class DeleteBinDir implements Runnable {
	public static void main(String[] args) {
		new DeleteBinDir("C:\\1").run();
	}

	private File root = null;

	public DeleteBinDir(String root) {
		this.root = new File(root);
	}

	public void run() {
		FileTraveller<Boolean> t = new FileTraveller<Boolean>(root, new SVNDirFilter(), new DeleteSVNDirProcessor());
		System.out.println("Start on: " + root.getAbsolutePath());
		t.run();
		System.out.println("Done!");
	}

	class SVNDirFilter implements Filter<File> {
		public boolean accept(File file) {
			if (null == file || false == file.exists() || false == file.isDirectory())
				return false;
			if (false == "lib".equals(file.getName()))
				return false;
			return true;
		}
	}

	class DeleteSVNDirProcessor implements FileProcessor<Boolean> {
		public Boolean operate(File file) {
			new DeleteDirectory(file).run();
			System.out.println(file.getAbsolutePath());
			return null;
		}
	}
}
